package cate.common.table.d;


import cate.common.table.common.ParamSheet;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

@NoteClass("阵营")
public class GDCamp {


    @NoteField("阵营克制属性")
    public static String COUNTER_ATTR_STR;


    @NoteClass("阵营-类型")
    public static final class Type {
        @NoteField("无阵营")
        public static final byte NULL = 0;

        @NoteField("水")
        public static final byte C1 = 1;

        @NoteField("火")
        public static final byte C2 = 2;

        @NoteField("木")
        public static final byte C3 = 3;

        @NoteField("土")
        public static final byte C4 = 4;

        @NoteField("光")
        public static final byte C5 = 5;

        @NoteField("暗")
        public static final byte C6 = 6;

        @NoteField("混沌")
        public static final byte C7 = 7;

        @NoteField("自然系阵营")
        public static final byte[] NATURE = new byte[]{C1, C2, C3, C4};

        @NoteField("光暗系阵营")
        public static final byte[] LIGHT_AND_DARK = new byte[]{C5, C6};

        @NoteField("全部普通阵营")
        private static final byte[] ALL_NORMAL = new byte[]{C1, C2, C3, C4, C5, C6};

        @NoteField(value = "全部阵营", detail = "包括混沌")
        private static final byte[] ALL = new byte[]{C1, C2, C3, C4, C5, C6, C7};

        public static boolean isNature(byte camp) {
            for (byte b : NATURE) {
                if (b == camp) {
                    return true;
                }
            }
            return false;
        }

        public static boolean isNiuBi(byte camp){
            for (byte b : LIGHT_AND_DARK) {
                if (b == camp) {
                    return true;
                }
            }
            return false;
        }

        public static byte[] getAllCamps(boolean includeChaos) {
            if (includeChaos) {
                return ALL;
            } else {
                return ALL_NORMAL;
            }
        }

        public static boolean valid(byte t, boolean includeChaos) {
            for (byte camp : getAllCamps(includeChaos)) {
                if (t == camp) {
                    return true;
                }
            }
            return false;
        }

        public static String description(Byte t) {
            if (t == null){
                return "NULL";
            }
            switch (t) {
                case NULL:
                    return "无阵营";
                case C1:
                    return "水";
                case C2:
                    return "火";
                case C3:
                    return "木";
                case C4:
                    return "土";
                case C5:
                    return "光";
                case C6:
                    return "暗";
                case C7:
                    return "混沌";
                default:
                    return "unsupported";
            }
        }

        /**
         * 是否阵营克制
         * @param cast
         * @param target
         * @return
         */
        public static boolean counter(byte cast, byte target) {
            switch (cast) {
                case C1:
                    return target == C2;
                case C2:
                    return target == C3;
                case C3:
                    return target == C4;
                case C4:
                    return target == C1;
                case C5:
                    return target == C6;
                case C6:
                    return target == C5;
                default:
                    return false;
            }
        }
    }


    public static void initialize(ParamSheet paramSheet) {
        COUNTER_ATTR_STR = GDParamTool.getString(paramSheet, 1301, "");
    }

}
